Repository navigation
perf: float64 dot and float32 Add/Sub/Mul/Div/Sqrt on go-simd/floats; delete the private kernels - #129
Merged
Conversation
…ernels dotSIMD is floats.Dot (v0.28.0) on every architecture. The dotFMA, dotNEON, dotLASX, dotVSX, dotRVV and dotVX kernels, hasFMA and their generator entries are gone; sum_*.s regenerated. TestDotSIMD now asserts the stated bound gamma_n*sum|a_i b_i| against a math/big oracle instead of bit equality. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the private kernels Bin32 and Sqrt32 call floats.Add32/Sub32/Mul32/Div32/Sqrt32 on every architecture (AVX2+SSE2 on amd64, NEON on arm64, portable elsewhere). The add32/sub32/mul32/div32/sqrt32 SSE2, NEON, LSX, VSX, RVV and VXE kernels and their generator entries are gone; sum_*.s regenerated. The wrappers still cut a and b to len(dst), so floats (which processes len(a) and panics on a shorter operand) never sees unequal lengths; a test pins it. The bit-identity tests against the scalar loop stay. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
added a commit
to go-simd/floats
that referenced
this pull request
Nov 22, 2026
…SX), riscv64 (RVV), s390x (VXE) (#75) The float32 elementwise kernels released in v0.30.0 had amd64 AVX2/SSE2 and arm64 NEON only; go-ndarray/ndarray#129 deletes ndarray's own kernels for these four architectures, so without them it is a regression there. Ported exactly from go-ndarray/ndarray at 7d5904e (internal/kernels/bin32_<arch>.go and asmgen/<arch>/gen.go): one IEEE binary32 operation per lane, Sqrt32 correctly rounded, generated by go-asmgen (binop32_<arch>_gen.go, diffed in CI like the amd64 and arm64 ones). Same length contract as binop32.go (first len(a) elements, dst may alias, an empty slice never reaches a kernel). Gates: hasLASX, hasVSX, hasRVV, hasVXE (the vars of the other kernels of the package); the portable loop behind them. Tests: a gate-off and gate-on rerun of the Add32..Sqrt32 suites per architecture, and TestSqrt32Exhaustive now on every architecture: all 2^32 patterns on amd64 and arm64, every 1021st (about 4.2 million) on the emulated ones and the portable targets. Kernels are unmeasured on hardware (QEMU lanes are not timings). Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
floats v0.32.0 carries the float32 Add/Sub/Mul/Div/Sqrt vector kernels for loong64, ppc64le, riscv64 and s390x, so no architecture loses its kernel by the deletion of the private ones. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rnels from 65536 elements) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ntf) Builder.Raw is printf-style; its first argument was built with fmt.Sprintf or string concatenation at 80 call sites in the amd64 and arm64 generators, which go vet reports as a non-constant format string. Pass the text through "%s" or as a real format with arguments. The regenerated sum_*.s files for all six architectures (asmgen/regen) are byte-identical: no assembly changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
added a commit
to go-blas/blas
that referenced
this pull request
Nov 23, 2026
…ntf) (#11) Builder.Raw is printf-style; its first argument was built with fmt.Sprintf or passed as a computed string at 79 call sites in the amd64 and arm64 generators, which go vet reports as a non-constant format string. Pass the text as a real format with arguments, or through "%s". The regenerated sum_*.s files for all six architectures (asmgen/regen) are byte-identical: no assembly changes. Same fix as go-ndarray/ndarray#129. Refs #10 Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
3 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #98
Refs #130
What
One implementation, in go-simd/floats (bumped to v0.35.0), for the float64 dot and the float32 elementwise kernels.
dotSIMDisfloats.Doton every architecture. Deleted:dotFMA,dotNEON,dotLASX,dotVSX,dotRVV,dotVX,hasFMA,dot_*.go.Bin32/Sqrt32callfloats.Add32/Sub32/Mul32/Div32/Sqrt32(AVX2+SSE2 on amd64, NEON on arm64, and since v0.32.0 LSX, VSX, RVV and VXE kernels ported exactly from this repo's, so loong64, ppc64le, riscv64 and s390x keep their vector kernels through floats). Deleted: the SSE2, NEON, LSX, VSX, RVV and VXEadd32/sub32/mul32/div32/sqrt32kernels andbin32_<arch>.go.sum_*.sregenerated for all six architectures.Contracts
TestDotSIMDasserts|got - exact| <= gamma_n * sum|a_i b_i|(gamma_n = nu/(1-nu), u = 2^-53, the go-blas Dot contract) against a math/big oracle for n = 0..70 and on random data. NaN/Inf propagation unchanged.float32(math.Sqrt(float64(x)))), and the bit-identity tests against the scalar loop are kept.len(a)and panics on a shorter operand.Bin32andSqrt32cuta,b,srctolen(dst), so no ndarray input reaches the floats panic;TestBin32OperandsLongerThanDstpins it. A shorter operand is refused by length, but see kernels: Bin32 and Sqrt32 read past a short operand's length when it has spare capacity #130: a reslice is checked against capacity, not length, so an operand shorter thanlen(dst)with spare capacity is over-read rather than refused. Not fixed here.Performance
Single core, AMD EPYC 7773X (linux/amd64),
taskset -c 9,GOMAXPROCS=1, NumPy 2.5.5 withOMP/OPENBLAS/MKL_NUM_THREADS=1(out=preallocated). Kernel-level Go benchmarks (internal/kernels:dotSIMD,MatVecP,Bin32,Sqrt32) built from the merge base 7d5904e ("before") and from the go-simd/floats v0.35.0 head ("after"). Median of 9 interleaved rounds (before, after, NumPy per round). ns/op, lower is better.Load caveat: cfarm420's 1-minute load was 6.6 to 7.1 when the rounds started and 12.2 at the end (other users; the benchmarks use one pinned core). The 1e6 rows are memory-bound and move by a few percent between rounds; the ratios are interleaved but treat 5 % as noise.
Against the bar (after no slower than before at every n, and no slower than NumPy where before was not):
Not measured: the other architectures (arm64, loong64, ppc64le, riscv64, s390x). The benchmark file and the NumPy script are not in the repo; they time the same data pattern on both sides. The v0.35.0 bump (go.mod, go.sum, bench/go.mod, bench/go.sum) is commit 4431f47 on top of the v0.32.0 head.
Checks run locally:
gofmt -lempty,go test ./...green,buildscan --vetis clean under all 21 CI configurations. The 7 "non-constant format string" vet reports that it found in theinternal/kernels/asmgengenerators were already on the merge base 7d5904e; they are fixed here in their own commit, 10e6607 (about 80 call sites, now constant formats), and regenerating all sixsum_*.sfrom it is byte-identical (git diff --exit-code -- '*.s').🤖 Generated with Claude Code